package tut.Struct.collection.phan1.compareableVsComparator;

import java.util.Iterator;
import java.util.TreeSet;

public class CompareableTest1 {

	public static void main(String[] args){
			TreeSet<Abs> set = new TreeSet<Abs>(new MyComparator());
			set.add(new Abs(-3));
			set.add(new Abs(-1));
			set.add(new Abs(-3));
			set.add(new Abs(-5));
			Iterator<Abs> iter = set.iterator();
			while(iter.hasNext()) {
				System.out.println(iter.next().a);
			}

			System.out.println("-----------");

			set = new TreeSet<Abs>();
			set.add(new Abs(-3));
			set.add(new Abs(-1));
			set.add(new Abs(-3));
			set.add(new Abs(-5));
			Iterator<Abs> iter2 = set.iterator();
			while(iter2.hasNext()) {
				System.out.println(iter2.next().a);
			}

		}
}

